<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
	$(function(){
		function n(n,e,t){
			return n.getAttribute(e)||t
		}
		function e(n){
			return document.getElementsByTagName(n)
		}
		function t(){
			var t=e("script"),o=t.length,i=t[o-1];
			return{l:o,z:n(i,"zIndex",-1),o:n(i,"opacity",.6),c:n(i,"color","46,139,87"),n:n(i,"count",150)}
		}
		function o(){
			a=m.width=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,
					c=m.height=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight
		}
		function i(){
			r.clearRect(0,0,a,c);
			var n,e,t,o,m,l;
			s.forEach(function(i,x){
				for(i.x+=i.xa,i.y+=i.ya,i.xa*=i.x>a||i.x<0?-1:1,i.ya*=i.y>c||i.y<0?-1:1,r.fillRect(i.x-.5,i.y-.5,1,1),e=x+1;e<u.length;e++)n=u[e],
				null!==n.x&&null!==n.y&&(o=i.x-n.x,m=i.y-n.y,
						l=o*o+m*m,l<n.max&&(n===y&&l>=n.max/2&&(i.x-=.03*o,i.y-=.03*m),
						t=(n.max-l)/n.max,r.beginPath(),r.lineWidth=t/2,r.strokeStyle="rgba("+d.c+","+(t+.2)+")",r.moveTo(i.x,i.y),r.lineTo(n.x,n.y),r.stroke()))
			}),
					x(i)
		}
		var a,c,u,m=document.createElement("canvas"),d=t(),l="c_n"+d.l,r=m.getContext("2d"),
				x=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||
						function(n){
							window.setTimeout(n,1e3/45)
						},
				w=Math.random,y={x:null,y:null,max:2e4};m.id=l,m.style.cssText="position:fixed;top:0;left:0;z-index:"+d.z+";opacity:"+d.o,e("body")[0].appendChild(m),o(),window.onresize=o,
				window.onmousemove=function(n){
					n=n||window.event,y.x=n.clientX,y.y=n.clientY
				},
				window.onmouseout=function(){
					y.x=null,y.y=null
				};
		for(var s=[],f=0;d.n>f;f++){
			var h=w()*a,g=w()*c,v=2*w()-1,p=2*w()-1;s.push({x:h,y:g,xa:v,ya:p,max:6e3})
		}
		u=s.concat([y]),
				setTimeout(function(){i()},100)
	});
</script>

<script>
	/* --   Beautiful Mouse  -- */
	var a_idx = 0;
	jQuery(document).ready(function ($) {
		$("body").click(function (e) {
			var a = new Array("❤富强❤", "❤民主❤", "❤和谐❤", "❤文明❤", "❤自由❤", "❤平等❤", "❤公正❤", "❤法治❤",
					"❤爱国❤", "❤敬业❤", "❤诚信❤", "❤友善❤");
			var $i = $("<span></span>").text(a[a_idx]);
			a_idx = (a_idx + 5) % a.length;
			var x = e.pageX,
					y = e.pageY;
			$i.css({
				"z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
				"top": y - 20,
				"left": x,
				"position": "absolute",
				"font-weight": "bold",
				"color": "rgb(" + Math.floor(Math.random() * 255) + "," + Math.floor(Math
						.random() * 255) + "," + Math.floor(Math.random() * 255) + ")"
			});
			$("body").append($i);
			$i.animate({
						"top": y - 180,
						"opacity": 1
					},
					3000,
					function () {
						$i.remove();
					});
		});
	});
</script>

<script>
	/*样式一*/
	(function($){
		$.fn.snow = function(options){
			var $flake = $('<div id="snowbox" />').css({'position': 'absolute','z-index':'9999', 'top': '0px'}).html('&#10052;'),
					documentHeight 	= $(document).height(),
					documentWidth	= $(document).width(),
					defaults = {
						minSize		: 10,
						maxSize		: 20,
						newOn		: 1000,
						flakeColor	: "#FFC0CB" /* 此处可以定义雪花颜色，若要白色可以改为#FFFFFF */
					},
					options	= $.extend({}, defaults, options);
			var interval= setInterval( function(){
				var startPositionLeft = Math.random() * documentWidth - 100,
						startOpacity = 0.5 + Math.random(),
						sizeFlake = options.minSize + Math.random() * options.maxSize,
						endPositionTop = documentHeight - 200,
						endPositionLeft = startPositionLeft - 500 + Math.random() * 500,
						durationFall = documentHeight * 10 + Math.random() * 5000;
				$flake.clone().appendTo('body').css({
					left: startPositionLeft,
					opacity: startOpacity,
					'font-size': sizeFlake,
					color: options.flakeColor
				}).animate({
					top: endPositionTop,
					left: endPositionLeft,
					opacity: 0.2
				},durationFall,'linear',function(){
					$(this).remove()
				});
			}, options.newOn);
		};
	})(jQuery);
	$(function(){
		$.fn.snow({
			minSize: 5, /* 定义雪花最小尺寸 */
			maxSize: 10,/* 定义雪花最大尺寸 */
			newOn: 1000  /* 定义密集程度，数字越小越密集 */
		});
	});
</script>


<script src="https://eqcn.ajz.miesnfu.com/wp-content/plugins/wp-3d-pony/live2dw/lib/L2Dwidget.min.js"></script>
<script>
	L2Dwidget.init({
		"model": { "jsonPath":"https://unpkg.com/live2d-widget-model-shizuku@1.0.5/assets/shizuku.model.json", "scale": 1, "hHeadPos":0.5, "vHeadPos":0.618 },
		"display": { "position": "right", "width": 100, "height": 200, "hOffset": 0, "vOffset": 0 },
		"mobile": { "show": true, "scale": 0.5 },
		"react": { "opacityDefault": 0.7, "opacityOnHover": 0.2 }
	});
</script>

<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">商品名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="goodsname1" id="goodsname1" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="button" id="searchbtn" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
      
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">出入库时间</label>
                            <div class="layui-input-inline">
                                <input type="date" name="actiondate1" id="actiondate1" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="button" id="searchbtn2" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        	
                        </div>
                        
                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>
            </div>
        </script>
		

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
		<script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
          
        </script>
       
		<script type="text/html" id="goodsnotesForm">
	
		<form class="layui-form" action="" lay-filter="goodsnotesForm">
<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label"></label>
      					<div class="layui-input-inline">
<input type="hidden" id="id" name="id" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
			<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label">商品名称</label>
      					<div class="layui-input-inline">
<input type="text" id="goodsname" name="goodsname" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
			<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label">生产公司</label>
      					<div class="layui-input-inline">
<input type="text" id="goodsfactory" name="goodsfactory" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
	

<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label">产品型号</label>
      					<div class="layui-input-inline">
<input type="text" id="goodsmodel" name="goodsmodel" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label">产品规格</label>
      					<div class="layui-input-inline">
<input type="text" id="goodssize" name="goodssize" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label">产品数量</label>
      					<div class="layui-input-inline">
<input type="text" id="goodsnumber" name="goodsnumber" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label">操作日期</label>
      					<div class="layui-input-inline">
<input type="date" id="actiondate" name="actiondate" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label">负责单位</label>
      					<div class="layui-input-inline">
<input type="text" id="actionpart" name="actionpart" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label">负责人</label>
      					<div class="layui-input-inline">
<input type="text" id="chargeman" name="chargeman" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
<div class="layui-form-item">
    				<div class="layui-inline">
      					<label class="layui-form-label">状态</label>
      					<div class="layui-input-inline">
<input type="text" id="status" name="status" lay-verify="required|phone" autocomplete="off" class="layui-input demo-phone">
      					</div>
    				</div>
  				</div>
               <div class="layui-form-item">
    				<div class="layui-input-block">
      					
							<button id="savebtn" type="button" class="layui-btn" >保存</button> 
							<button type="reset" class="layui-btn" >重置</button> 
      				
    				</div>
  				</div>
		</form>
</script>
    </div>
</div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','layer','laydate'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layer= layui.layer
            laydate=layui.laydate
            ;
        //对搜索写操作
        $("#searchbtn").on("click",function(){
        	
        	   table.render({
                   elem: '#currentTableId',
                   url: '/goodsnotes',    
            		where:{keyword:$("#goodsname1").val(),action:"list"},
                   cols: [[
                       {type: "checkbox", width: 50},
                       {field: 'id', width: 100, title: 'ID', sort: true},
                       {field: 'goodsname', width: 100, title: '产品名称'},
                       {field: 'goodsfactory', width: 100, title: '成产厂家', sort: true},
                       {field: 'goodsmodel', width: 100, title: '产品型号'},
                       {field: 'goodssize', title: '产品规格', minWidth: 100},
                       {field: 'goodsnumber', minWidth: 100, title: '产品数量'},
                       {field: 'actiondate', minWidth: 100, title: '操作日期'},
                       {field: 'actionpart', minWidth: 100, title: '负责单位'},
                       {field: 'chargeman', minWidth: 100, title: '负责人'},
                       {field: 'status', minWidth: 100, title: '状态'},
                       {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
                       
                   ]],
                   limits: [10, 15, 20, 25, 50, 100],
                   limit: 15,
                   page: true,
                   skin: 'line'
               }) ;
        
        	}).click();
        //对搜索2写操作
        $("#searchbtn2").on("click",function(){
        	
        	   table.render({
                   elem: '#currentTableId',
                   url: '/goodsnotes',    
            		where:{keyword:$("#actiondate1").val(),action:"list2"},
                   cols: [[
                       {type: "checkbox", width: 50},
                       {field: 'id', width: 100, title: 'ID', sort: true},
                       {field: 'goodsname', width: 100, title: '产品名称'},
                       {field: 'goodsfactory', width: 100, title: '成产厂家', sort: true},
                       {field: 'goodsmodel', width: 100, title: '产品型号'},
                       {field: 'goodssize', title: '产品规格', minWidth: 100},
                       {field: 'goodsnumber', minWidth: 100, title: '产品数量'},
                       {field: 'actiondate', minWidth: 100, title: '操作日期'},
                       {field: 'actionpart', minWidth: 100, title: '负责单位'},
                       {field: 'chargeman', minWidth: 100, title: '负责人'},
                       {field: 'status', minWidth: 100, title: '状态'},
                       {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
                   ]],
                   limits: [10, 15, 20, 25, 50, 100],
                   limit: 15,
                   page: true,
                   skin: 'line'
               }) ;
        
        	});
        
        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });
		//每条员工记录的删除或者修改
        table.on('tool(currentTableFilter)', function (obj) {
        	
            if(obj.event == "edit"){
            	$.get("/goods?id="+obj.data.id,function(depts
            			){
            		//查成功之后走下面的代码
                	layer.open({
                		type:1,
                		title:"修改订单信息",
                		area:["400px","600px"],
                		content:$("#goodsnotesForm").html()
                	});
            
                	//渲染表单
                    form.render();  
                	//为input内传默认值
                	var emp =obj.data;
                	$("#id").val(emp.id);
                	$("#goodsname").val(emp.goodsname);
                	$("#goodsfactory").val(emp.goodsfactory);
                	$("#goodsmodel").val(emp.goodsmodel);
                	$("#goodssize").val(emp.goodssize);
                	$("#goodsnumber").val(emp.goodsnumber);
                	$("#actiondate").val(emp.actiondate);
                	$("#actionpart").val(emp.actionpart);
                	$("#chargeman").val(emp.chargeman);
                	$("#status").val(emp.status);
                	laydate.render({
            			elem:'#actiondate'
            		});
                	 form.render();	
                    //绑定保存按钮的事件
                    $("#savebtn").on("click",function(){
                    	//打包form表单中的所有数据
                    	var data=form.val("goodsnotesForm");
                    	data.action='save3';//edit
                    	//发请求把数据推送到后台
                    	$.post("/goods",data,function(){
                    		//请求成功后，1关窗口，2，点搜索
                    		layer.closeAll();
                    		$("#searchbtn").click();
                    	});
                    });
                  
                    //渲染表单
                    form.render();	
            
            });}
            if(obj.event == "delete"){
            	layer.confirm("您要出库该产品吗?",function(){
            		//通知后台删除该员工(发请求)
            		$.post("/goods",{id:obj.data.id,action:"delete"},function(){
            			//关窗口
            			layer.closeAll();
            			//重新渲染一边table表格数据
            			$("#searchbtn").click();
            		});
            	});
            }      
        });

    });
</script>

</body>
</html>